package com.woniu.defecttracking.controller.datas;


import com.woniu.defecttracking.commens.Result;
import com.woniu.defecttracking.exception.MenusException;
import com.woniu.defecttracking.exception.RuleException;
import com.woniu.defecttracking.param.AddRuleMenusParam;
import com.woniu.defecttracking.service.RuleMenusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 倪西
 * @since 2021-12-31
 */
@RestController
@RequestMapping("/ruleMenus")
public class RuleMenusController {

    @Autowired
    private RuleMenusService ruleMenusService;

    /**
    * @作者: 倪西
    * @描述：新增rule和菜单的关联
    * @时间：2022/1/7 21:57
    * @参数：[addRuleMenusParam]
    * @返回：com.woniu.defecttracking.commens.Result
    **/
    @PostMapping("/addRuleMenus")
    public Result addRuleMenus(@RequestBody AddRuleMenusParam addRuleMenusParam) throws MenusException, RuleException {
        Boolean bool = ruleMenusService.saveRuleMenus(addRuleMenusParam);
        if (bool){
            return Result.getInstance(null).setMessage("授权成功");
        }else {
            return Result.getInstance(null).setCode(911).setMessage("授权失败");
        }
    }
}

